package com.shangye.core;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class ClientHandler implements Runnable{
    private Socket socket;
    public ClientHandler(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {

        try {
            InputStream inputStream = socket.getInputStream();

            int d;
            StringBuilder builder = new StringBuilder();
            char pre = 'a',cur = 'a';
            while ((d = inputStream.read())!=-1){
                cur = (char)d;
                if (pre==13&&cur==10){
                    break;
                }
                pre = cur;
                builder.append(pre);
            }
            System.out.println("builder:" + builder);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
